/*
 * @(#)UraInvokerTestCase.java $version 2010. 8. 11
 *
 * Copyright 2007-2010 NHN Corp. All rights Reserved. 
 * NHN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.nhncorp.usf.core.invoker;

import static org.junit.Assert.*;

import java.util.HashMap;
import java.util.Map;

import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.w3c.dom.Document;

import com.nhncorp.lucy.common.container.SpringBeanFactory;
import com.nhncorp.lucy.common.util.ResourceLoader;
import com.nhncorp.lucy.common.util.XMLDOMUtil;
import com.nhncorp.usf.core.call.ReturnValue;
import com.nhncorp.usf.core.config.ConfigurationBuilder;

/**
 * @author Web Platform Development Team
 */
@Ignore
public class UraInvokerTestCase {

    @BeforeClass
    public static void initialize() throws Exception {

        ResourceLoader loader = new ResourceLoader();
        Document document = XMLDOMUtil.loading(loader
                .getResourceAsStream("configuration.xml"), true);
        ConfigurationBuilder builder = new ConfigurationBuilder();
        builder.build(document.getDocumentElement());

        SpringBeanFactory.init(new ClassPathXmlApplicationContext("applicationContext-bo.xml"));
    }

    @SuppressWarnings("unchecked")
    @Test
    public void lucySpringInvokerTest() throws Exception {
        Map<Object, Object> params = new HashMap<Object, Object>();
        params.put("userId", "answer");
        Invoker invoker = new SpringInvoker();
        ConnectorHolder connectorHolder = new ConnectorHolder(invoker);
        InvocationFuture future = connectorHolder.invoke(
                "com.nhncorp.usf.core.service.mock.MockBlogBO",
                "getBlog",
                params
        );
        Map<Object, Object> returnValue
                = (Map<Object, Object>)((ReturnValue)future.await().getReturnValue()).get();
        assertEquals("songsblog", returnValue.get("title"));
    }

}
